package com.hry.store.service.impl;

import com.hry.store.dao.ProductColorMapper;
import com.hry.store.pojo.ProductColor;
import com.hry.store.service.ProductColorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ProductColorServiceImpl implements ProductColorService {
    @Autowired
    private ProductColorMapper productColorMapper;
    /**
     * 根据产品id，版本id查询颜色分类
     * @param secondCategoryId
     * @param versionId
     * @return
     */
    @Override
    public List<ProductColor> getProductColorBySecondCategoryIdAndVersionId(Integer secondCategoryId, Integer versionId) {
        List<ProductColor> productColorList = productColorMapper.getProductColorBySecondCategoryIdAndVersionId(secondCategoryId, versionId);
        return productColorList;
    }

    /**
     * 查询版本颜色对应的图片
     * @param secondCategoryId
     * @param versionId
     * @return
     */
    @Override
    public List getProductImgs(Integer secondCategoryId, Integer versionId, String colorName) {
        ProductColor productColor = productColorMapper.getProductImgs(secondCategoryId, versionId, colorName);
        String images = productColor.getProductImgs();
        String[] image = images.split(",");
        List list = new ArrayList();
        for (String img : image) {
            list.add(img);
        }
        return list;


    }
}
